#include "Precompile.h"
#include "ICamera.h"

namespace Utility{
	void ICamera::createProjectionMatrix(float aspectRatio, float fovAngle, float nearPlane, float farPlane){
		m_projectionMatrix.identity();

		float cotFOV = float(1.0/tan(fovAngle/2.0f));

		m_projectionMatrix.set(0,0,(1.0f/aspectRatio)*cotFOV);
		m_projectionMatrix.set(1,1,cotFOV);
		m_projectionMatrix.set(2,2,farPlane/(farPlane-nearPlane));
		m_projectionMatrix.set(2,3,1.0f);
		m_projectionMatrix.set(3,2,-(((farPlane)/(farPlane-nearPlane))*nearPlane));
		m_projectionMatrix.set(3,3,0.0f);
	}

	Math::Matrix<4,4>& ICamera::getViewProjection(){
		return m_viewProjMatrix;
	}

	Math::Matrix<4,4>& ICamera::getViewMatrix(){
		return m_viewMatrix;
	}

	Math::Matrix<4,4>& ICamera::getProjectionMatrix(){
		return m_projectionMatrix;
	}
}